import { menu } from '../../../app/decorator';
import BaseColorShap from './base/BaseColorShap';

const { ccclass, disallowMultiple, executeInEditMode } = cc._decorator;

@ccclass
@menu(__filename, '圆形')
@disallowMultiple()
@executeInEditMode()
export default class ColorShapCircle extends BaseColorShap {

    onDraw(cxt: cc.Graphics, centerX: number, centerY: number) {

        // rx与ry不相等为椭圆形
        const rx = this.node.width / 2, ry = this.node.height / 2;
        if (rx > 0 && ry > 0) {
            if (rx === ry) {
                cxt.circle(centerX, centerY, rx);
            } else {
                cxt.ellipse(centerX, centerY, rx, ry);
            }
        }
    }
}
